<?php
namespace app\index\controller;

use think\Request;
use app\index\model\Visits;
use app\index\model\Earnings;

class Statistics extends Common
{
    public function index(Request $request)
    {
        $search_type = $request->param('type', 'today', 'filterString');  //查询类型
        if ($request->param('starttime')) {
            $this->assign('starttime', $request->param('starttime', '', 'filterString'));
        }
        if ($request->param('endtime')) {
            $this->assign('endtime', $request->param('endtime', '', 'filterString'));
        }
        $visits = new Visits();
        $earnings = new Earnings();
        $visits_data = $visits->statsByTime($search_type, true);      //访问量统计
        $earnings_data = $earnings->statsByTime($search_type, true);  //收益统计
        $this->assign('type', $visits_data['type']);
        $this->assign('visits_data', $visits_data['data']);
        $this->assign('earnings_data', $earnings_data['data']);
        $this->assign('header_name', '渠道总收益');
        $this->assign('header_info', '（数据有1-2个小时延迟）');
        return $this->fetch();
    }


}
